<%@page language="java" pageEncoding="UTF-8" %>

<html>
<head>
    <title>login</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <meta content="text/html;charset=UTF-8" http-equiv="content-type"/>
    <style type="text/css" rel="stylesheet">
        body {
            margin: 0;
            padding: 0;
            background-color: antiquewhite;
            overflow: hidden;
        }
        canvas {
            display: block;
        }
        .login-main {
            width: 500px;
            height: 300px;
            position: absolute;
            top: 50%;
            left: 50%;
            margin: -150px 0px 0px -250px;
            background-color: bisque;
            border-style: solid;
            border-width: 1px;
            border-color: #FFFFFF;
            border-radius: 15px;
            box-shadow: 0px 0px 5px #333333;
            opacity: 90%;
        }
        .login-in input {
            width: 200px;
            height: 35px;
        }
        .login-in div {
            margin-bottom: 5px;
        }
        .login-in {
            margin-left: 120px;
            position: absolute;
            margin-top: 100px;
        }
        #login-msg {
            font-size: 13px;
            color: red;
        }
    </style>
    <script language="JavaScript" type="application/javascript">
        function postForm(URL, PARAMTERS, target) {
            if (!PARAMTERS['token']) {
                PARAMTERS['token'] = getToken();
            }
            //创建form表单
            var temp_form = document.createElement("form");
            temp_form.action = URL;
            //如需打开新窗口，form的target属性要设置为'_blank'
            temp_form.target = target ? target : "_self";
            temp_form.method = "post";
            temp_form.style.display = "none";
            //添加参数
            for (var item in PARAMTERS) {
                var opt = document.createElement("input");
                opt.name = item;
                opt.value = PARAMTERS[item];
                temp_form.appendChild(opt);
            }
            document.body.appendChild(temp_form);
            //提交数据
            temp_form.submit();
            $(temp_form).remove();
        }
        function login() {
            var username = $("#login-username").val();
            var password = $("#login-password").val();
            if (username == "") {
                $("#login-msg").html("用户名必填");
                return;
            }
            if (password == "") {
                $("#login-msg").html("密码必填");
                return;
            }
            $.post("/api/user/login", {
                "username": username,
                "password": password
            }, function (data) {
                if (data.state && data.state != 0) {
                    $("#login-msg").html(data.message);
                } else {
                    localStorage.setItem("token", data.token);
                    postForm("/api/resume/resume", {"token": data.token});
                }
            });
        }
        function enter() {
            e = window.event;
            if (e.keyCode == 13) {
                login();
            }
        }
    </script>
</head>
<body onkeydown="enter()">
    <div class="login-main">
        <div class="login-in">
            <div class="login-user">
                <label for="login-username">用户:</label>
                <input id="login-username" name="username" value="" autofocus/>
            </div>
            <div class="login-pswd">
                <label for="login-password">密码:</label>
                <input id="login-password" name="password" value="" type="password"/>
            </div>
        <div class="login-submit">
            <button id="login-submit" onclick="login()">登录</button>
            <span id="login-msg"></span>
        </div>
        </div>
    </div>


    <canvas id="c"></canvas>
    <script type="text/javascript" src='/js/TweenMax.min.js'></script>
    <script type="text/javascript" src="/js/index.js"></script>
</body>
</html>
